#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
#if UNITY_EDITOR
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Serialization;
using UnityEditor;
using UnityEngine;
using System.Reflection;
using System.Collections.Generic;
using System.Runtime.InteropServices;



public class AkUtilities
{
	
	// Make two paths relative to each other
	public static string MakeRelativePath(string fromPath, string toPath)
	{
		try
		{
			if (string.IsNullOrEmpty(fromPath))
			{
				return toPath;
			}
			
			if (string.IsNullOrEmpty(toPath))
			{
				return "";
			}
			
			Uri fromUri = new Uri(fromPath);
			Uri toUri = new Uri(toPath);
			
			if (fromUri.Scheme != toUri.Scheme) { return toPath; } // path can't be made relative.
			
			Uri relativeUri = fromUri.MakeRelativeUri(toUri);
			string relativePath = Uri.UnescapeDataString(relativeUri.ToString());
			
			return relativePath;
		}
		catch
		{
			return toPath;
		}
	}
	
	// Reconcile a base path and a relative path to give a full path without any ".."
	public static string GetFullPath(string BasePath, string RelativePath)
	{
		string tmpString;
		if (string.IsNullOrEmpty(BasePath))
		{
			return "";
		}
		
		char wrongSeparatorChar = (Path.DirectorySeparatorChar == '/') ? '\\' : '/';
		
		if( string.IsNullOrEmpty(RelativePath))
		{
			return BasePath.Replace(wrongSeparatorChar, Path.DirectorySeparatorChar);
		}
		
		if (Path.GetPathRoot(RelativePath) != "")
		{
			return RelativePath.Replace(wrongSeparatorChar, Path.DirectorySeparatorChar);
		}
		
		tmpString = Path.Combine(BasePath, RelativePath);
		tmpString = Path.GetFullPath(new Uri(tmpString).LocalPath);
		
		return tmpString.Replace(wrongSeparatorChar, Path.DirectorySeparatorChar);
	}
	

    
	public class ShortIDGenerator
    {
        static ShortIDGenerator()
        {
            HashSize = 32;
        }

        public static byte HashSize
        {
            get
            {
                return s_hashSize;
            }

            set
            {
                s_hashSize = value;
                s_mask = (uint)((1 << s_hashSize) - 1);
            }
        }

        public static uint Compute(string in_name)
        {
            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(in_name.ToLower());

            // Start with the basis value
            uint hval = s_offsetBasis32;

            for (int i = 0; i < buffer.Length; i++)
            {
                // multiply by the 32 bit FNV magic prime mod 2^32
                hval *= s_prime32;

                // xor the bottom with the current octet
                hval ^= buffer[i];
            }

            if (s_hashSize == 32)
                return hval;

            // XOR-Fold to the required number of bits
            return (hval >> s_hashSize) ^ (hval & s_mask);
        }

        private static byte s_hashSize;
        private static uint s_mask;

        private const uint s_prime32 = 16777619;
        private const uint s_offsetBasis32 = 2166136261;
    }
#if UNITY_EDITOR
    public static void OnAudioInitialize()
    {
#if UNITY_2017_2_OR_NEWER
        EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
        EditorApplication.pauseStateChanged += OnPauseStateChanged;
#else
        EditorApplication.playmodeStateChanged += OnEditorPlaymodeStateChanged;
#endif
    }

    public static void OnAudioDestroy()
    {
#if UNITY_2017_2_OR_NEWER
        EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
        EditorApplication.pauseStateChanged -= OnPauseStateChanged;
#else
        EditorApplication.playmodeStateChanged -= OnEditorPlaymodeStateChanged;
#endif
    }

#if UNITY_2017_2_OR_NEWER
    private static void OnPlayModeStateChanged(PlayModeStateChange playMode)
    {
        if (playMode == PlayModeStateChange.EnteredPlayMode)
            ActivateAudio(true);
        else if (playMode == PlayModeStateChange.ExitingPlayMode)
            ActivateAudio(false);
    }

    private static void OnPauseStateChanged(PauseState pauseState)
    {
        ActivateAudio(pauseState != PauseState.Paused);
    }
#else
    private static void OnEditorPlaymodeStateChanged()
    {
        ActivateAudio(!EditorApplication.isPaused);
    }
#endif

    public static void ActivateAudio(bool activate)
    {

        if (activate)
            AkSoundEngine.WakeupFromSuspend();
        else
            AkSoundEngine.Suspend();

        AkSoundEngine.RenderAudio();

    }
#endif
	
	
}
#endif // UNITY_EDITOR


#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.